package com.sunfeng.elasticsearch.es.utils;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

/**
 * @Author : 孙峰
 * @Description:
 * @Date : 2022/9/29  11:36
 */
public class DateTimeFormatterUtil {
	public static final DateTimeFormatter yyyyMM = DateTimeFormatter.ofPattern("yyyyMM");
	public static final DateTimeFormatter yyyyMMddHH = DateTimeFormatter.ofPattern("yyyyMMddHH");
	public static final DateTimeFormatter yyyyMMddHHmmss = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
	public static final DateTimeFormatter yyyy_MM_dd_HH_mm_ss= DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

	public static final  DateTimeFormatter yyyy_MM_dd_HH_mm_ss_SSS=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");

	public static final  DateTimeFormatter yyyy_MM_dd_T_HH_mm_ss_SSS_Z=DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");

	public static final DateTimeFormatter yyyy_MM= DateTimeFormatter.ofPattern("yyyy-MM");
	public static LocalDateTime getDateTimeOfTimestamp(long timestamp) {
		Instant instant = Instant.ofEpochMilli(timestamp);
		ZoneId zone = ZoneId.systemDefault();
		return LocalDateTime.ofInstant(instant, zone);
	}
}
